
class SecondUI extends egret.Sprite {
    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.createView, this);
    }
    private createView(): void {
        //添加背景
        var bg = createBitmap("bgsec_png");
        this.addChild(bg);
        //雪花背景
        var snowflake_1 = createBitmap("one_snowflower_png", 0, 0);
        var snowflake_2 = createBitmap("one_snowflower_png", 0, -1206);
        this.addChild(snowflake_1);
        this.addChild(snowflake_2);
        egret.Tween.get(snowflake_1, { loop: true }).to({ y: 1206 }, 10000);
        egret.Tween.get(snowflake_2, { loop: true }).to({ y: 0 }, 10000);
        //flor
        var se_flor = createBitmap("one_snow_png", 0, 850);
        this.addChild(se_flor);
        //标题
        var title = createBitmap("three_title_png", 0, 100);
        this.addChild(title);
        //铃铛
        var bell = createBitmap("three_bell_png", 29, 233);
        this.addChild(bell);
        //袜子
        var sock = createBitmap("three_sock_png", 656, 206);
        this.addChild(sock);
        //背景树
        var tree = createBitmap("three_tree_png", 50, 595);
        this.addChild(tree);
        //人物
        var man = createBitmap("three_man_png", 123, 289);
        this.addChild(man);
        egret.Tween.get(man, { loop: true }).to({ y:295}, 100).to({ y:289}, 100);
        //手上的礼物
        var handgift = createBitmap("three_handgift_png", 176, 588);
        this.addChild(handgift);
        handgift.anchorOffsetX = handgift.width * .5;
        handgift.anchorOffsetY = handgift.height * .5;
        egret.Tween.get(handgift, { loop: true }).to({ y:544}, 200).to({ y:538}, 130).to({rotation: 360,},1000);
        //鹿
        var fawn = createBitmap("three_fawn_png", 40, 720);
        this.addChild(fawn);

        //开始游戏按钮
        var se_btn1 = createBitmap("start_btn_png")
        this.addChild(se_btn1)
        se_btn1.anchorOffsetX = se_btn1.width * .5;
        se_btn1.anchorOffsetY = se_btn1.height * .5;
        se_btn1.x = 380;
        se_btn1.y = 1090;
        se_btn1.touchEnabled = true
        egret.Tween.get(se_btn1, { loop: true }).to({ scaleX: 1.2, scaleY: 1.2 }, 1000);
        var flor2 = createBitmap("three_iceflat_png", 0, 1080)
        this.addChild(flor2)
        //我的奖品
        var Prize = createBitmap("three_giftbg_png", 543, 1011);
        Prize.visible = false;
        this.addChild(Prize);

        var Prize1 = createBitmap("three_gift_png", 600, 1060);
        Prize1.visible = false;
        this.addChild(Prize1);

        var Prize2 = createTextFiled("我的奖品", 580, 1020, 30, 0x000000);
        Prize2.visible = false;
        this.addChild(Prize2);

        var Prize3 = createTextFiled("游 戏 规 则", 326, 1144, 30, 0x717171);
        this.addChild(Prize3);
        var _xiahua = new egret.DisplayObjectContainer();
        var leftCage1 = new egret.Shape();
        leftCage1.graphics.lineStyle(2, 0x707070)
        leftCage1.graphics.lineTo(320, 1172);
        leftCage1.graphics.lineTo(450, 1172);
        leftCage1.graphics.endFill();
        _xiahua.addChild(leftCage1);
        this.addChild(_xiahua);
        Prize3.touchEnabled = true;

        //游戏规则
        var leftCon = new egret.DisplayObjectContainer();
        var leftCage = new egret.Shape();
        leftCage.graphics.lineTo(0, 0);
        leftCage.graphics.lineTo(750, 0);
        leftCage.graphics.lineTo(750, 1206);
        leftCage.graphics.lineTo(0, 1206);
        leftCage.graphics.lineTo(0, 0);
        leftCage.graphics.endFill();
        leftCon.addChild(leftCage);
        leftCon.x = 0;
        leftCon.y = 0;

        var rule_bg = createBitmap("rule_bg_png", 17, 44, );
        leftCon.addChild(rule_bg);
        var title2 = createTextFiled("游戏规则", 275, 130, 48, 0xffffff);
        leftCon.addChild(title2);
        var rule_main = createTextFiled("在游戏规定时间60秒内，点击富力房产 logo和圣诞节logo即可得分，误点到炸弹将扣除相应分数！", 90, 220, 29, 0xffffff, "left", 560);
        rule_main.lineSpacing = 19;
        leftCon.addChild(rule_main);
        var rule_first = createTextFiled("1、累积得分满10000分，可获得一次抽奖机会！\n2、得分未满10000分，可选择继续游戏或分享游戏给好友得现金豪礼；\n<1>累积满10000分，即可获得抽奖资格；\n<2>分享给好友，好友点击打开后，玩家将获得现金豪礼！（系统后台发送，直接到帐微信钱包！）\n3、每人各有一次抽奖机会和领取现金豪礼机会；\n4、系统将保留个人游戏记录，中奖用户须填写个人资料，验证成功后方可抽奖，仅限中奖者本人领奖，作弊用户直接取消获奖资格，我们保留追求其责任的权利。", 90, 365, 29, 0xffffff, "left", 563);
        rule_first.lineSpacing = 19;
        leftCon.addChild(rule_first);
        var claus = createBitmap("claus_png", 490, 980);
        leftCon.addChild(claus);
        this.addChild(leftCon);
        leftCon.visible = false;
        leftCon.touchEnabled = true;
        //暂时隐藏
        //打开规则弹窗
        Prize3.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            leftCon.visible = true;
            leftCon.scaleX = 1;
            leftCon.scaleY = 0;
            egret.Tween.get(leftCon).to({ scaleX: 1, scaleY: 1 }, 500).call(function () { })
            Prize3.touchEnabled = false;
        }, this);
        //关闭规则弹窗
        leftCon.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            egret.Tween.get(leftCon).to({ scaleX: 1, scaleY: 0 }, 500).call(function () { leftCon.visible = false; })
        }, this)
        //我的奖品按钮
        Prize1.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            egret.Tween.get(win_result).to({ scaleX: 1, scaleY: 1 }, 500).call(function () {});
            win_result.visible = true;
            Prize1.touchEnabled = false;
        }, this)
        //开始游戏按钮
        se_btn1.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            SenceManage.create(this.stage).loadSence("preload", null, ResultUI);
            egret.Tween.get(this).to({x:-640},500);
        se_btn1.touchEnabled = false;
        }, this)
        //前往我的奖品
        var win_result = div(0, 0, 750, 0, 750, 1206, 0, 1206, 0, 1206, 0, 0);           //添加容器
        this.addChild(win_result);
        win_result.anchorOffsetX =  win_result.width * .5;
			win_result.anchorOffsetY = win_result.height * .5;
            win_result.x = win_result.width * .5;
			win_result.y = win_result.height * .5;
        //添加背景
        var bg2 = createBitmap("bgsec_png");
        win_result.addChild(bg2);
        //雪花背景
        var snowflake1 = createBitmap("one_snowflower_png", 0, 0);
        var snowflake2 = createBitmap("one_snowflower_png", 0, -1206);
        win_result.addChild(snowflake1);
        win_result.addChild(snowflake2);
        egret.Tween.get(snowflake1, { loop: true }).to({ y: 1206 }, 10000);
        egret.Tween.get(snowflake2, { loop: true }).to({ y: 0 }, 10000);
        var winningImg = createBitmap("winresultPink_png", 30, 20);             //添加标题粉红背景图
        win_result.addChild(winningImg)

        var win_title = createTextFiled("中  奖  了 ！", 117, 25, 48, 0xffffff, "center", 560, 88, "middle");                                                                  //添加标题
        win_title.bold = true;
        win_result.addChild(win_title);

        var win_bgmsg = createBitmap("winresultBg_png", 20, 147);
        win_result.addChild(win_bgmsg);

        var jpmc = createTextFiled("( 奖品名称 )", 270, 860, 35, 0xffffff, "center", 200, 50, "middle");
        jpmc.bold = true;
        win_result.addChild(jpmc);
        var win_receive = createTextFiled("已被你翻牌，请火速前来领取", 0, 910, 28, 0xffffff, "center", 750, 50, "middle");
        win_receive.bold = true;
        win_result.addChild(win_receive);

        var place = createTextFiled("领取地址：", 120, 1020, 28, 0xffffff, "left");
        win_result.addChild(place);

        var ad = createTextFiled("广州海珠区新港东路中洲交易中心8888号2999室", 260, 1020, 28, 0xffffff, "left", 380);
        ad.lineSpacing = 10;
        win_result.addChild(ad);

        var receive_methed = createTextFiled("领取方式：", 120, 1100, 28, 0xffffff, "left");
        //    receive_methed.bold = true;
        win_result.addChild(receive_methed);

        var time = createTextFiled("2016年05月15日-2017年04月30日到现场领取", 260, 1100, 28, 0xffffff, "left", 380);
        time.lineSpacing = 10;
        win_result.addChild(time);
        win_result.touchEnabled = true;
        win_result.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            egret.Tween.get(win_result).to({ scaleX: 0, scaleY: 0 }, 1000).call(function () { win_result.visible = false; })
        }, this)
        win_result.visible=false;
    }
}

